var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var session = require("express-session")

var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
var menuRouter = require('./routes/menu');
var cityRouter = require('./routes/city');

var app = express();
//session  配置
app.use(session({
    secret:"dfjdlfajdfafdafadfadaf",
    cookie:{maxAge:1000*60*60*24},
    resave:true,
    saveUninitialized:true
}))
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', indexRouter);// login methods  post方法
app.use('/users', usersRouter);
app.use("/menu",menuRouter)
app.use('/city',cityRouter)

module.exports = app;
